import axios from '@/utils/request'

// 获取员工数据
export const getEmployeeList = params => {
  return axios({
    url: '/sys/user',
    params
  })
}

// 导出员工数据
export const exportEmpDataByExcel = () => {
  return axios({
    url: '/sys/user/export',
    responseType: 'blob'
  })
}

// 员工导入模版下载
export const getEmpTemplate = () => {
  return axios({
    url: '/sys/user/import/template',
    responseType: 'blob'
  })
}

// 文件上传
export const exportFile = data => {
  return axios({
    url: '/sys/user/import',
    method: 'post',
    data // 此处data是form-data类型

  })
}

// 删除员工
export const delEmployee = id => {
  return axios({
    url: '/sys/user/' + id,
    method: 'delete'
  })
}

// 新增员工
export const addEmployee = data => {
  return axios({
    url: '/sys/user',
    method: 'post',
    data
  })
}

// 获取员工详情
export const getEmployeeDetail = id => {
  return axios({
    url: `/sys/user/${id}`
  })
}

// 编辑员工
export const updateEmployee = data => {
  return axios({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}

// 获取角色列表
export const getRoleList = () => {
  return axios({
    url: '/sys/role/list/enabled'
  })
}

// 更改员工角色
export const updateEmpRole = data => {
  return axios({
    url: '/sys/user/assignRoles',
    method: 'put',
    data
  })
}
